package model;

import java.util.Timer;
import java.util.TimerTask;

import javax.swing.ImageIcon;



public class Console extends java.util.Observable {

	Timer timerT;
	boolean isStarted = false;
	boolean flag = true;
	final String PATH1 = "/Users/vincentpoulain/Dropbox/NF28/TD1/workspace/TD1/img/lune.gif";
	final String PATH2 = "/Users/vincentpoulain/Dropbox/NF28/TD1/workspace/TD1/img/soleil_intro.jpg";
	public Console(){
		super();
		timerT = null;
	}
	public void timer(){
		if(flag){
			setChanged();
			this.notifyObservers(PATH1);
		}
		else{
			setChanged();
			this.notifyObservers(PATH2);
		}
		flag=!flag;
		
	}
	
	public void start(int freq){
		if(freq<0)
			return;
		if(timerT!=null){
			timerT.cancel();
		}

		timerT = new Timer();
		timerT.schedule(new changeImage(),0, freq*1000);
		
	}
	
	public void stop(){
		timerT.cancel();
		
	}
	
	class changeImage extends TimerTask {
		@Override
		public void run() {
			timer();
		}
		
	}
	
}
